const { Schema, model } = require('mongoose')

const accountSchema = new Schema({
    __v: {
        type: Number,
        select: false
    },
    // 记账标题
    title: {
        type: String,
        required: true
    },
    // 记账类型
    type: {
        type: String,
        enum: ['income', 'expenditure'], // ['收入','支出']
        default: 'income',
        required: true
    },
    // 记账备注
    remark: {
        type: String
    },
    // 钱的用途
    purpose: {
        type: Schema.Types.ObjectId, 
        ref: 'Purpose'
    }
}, { timestamps: true })

module.exports = model('Account', accountSchema)